﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ManageSystem
{
    public partial class VisitorForm : Form
    {

        MyBorrow myBorrow;
        public VisitorForm()
        {
            InitializeComponent();
        }

        public VisitorForm(string userId, string userName)
        {
            InitializeComponent();
            UserId.Text = userId;
            UserName.Text = userName;

        }
        private void timer_Tick(object sender, EventArgs e)
        {
            this.toolStripStatusLabel3.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
        }

        private void VisitorForm_Load(object sender, EventArgs e)
        {
            this.toolStripStatusLabel3.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            this.timer.Interval = 1000;
            this.timer.Start();
        }

        private void 我的借阅ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (myBorrow == null)
            {
                myBorrow = new MyBorrow(UserId.Text);
                myBorrow.FormBorderStyle = FormBorderStyle.None;
                myBorrow.Dock = DockStyle.Fill;
                myBorrow.TopLevel = false;
            }
            this.panel1.Controls.Clear();
            this.panel1.Controls.Add(myBorrow);
            //obj.MdiParent = this;
            myBorrow.Show();
        }



        private void toolStripStatusLabel2_Click(object sender, EventArgs e)
        {

        }

        private void 我的信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MyInfo my = new MyInfo(UserId.Text);
            my.Show();
        }

        private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ChangePwd change = new ChangePwd(UserId.Text);
            change.Show();
        }



        private void 退出登陆ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要退出登陆？", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {

                LoginForm login = (LoginForm)this.Owner;
                login.Show();
                this.Hide();
            }
        }

        void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show("确定要退出系统么?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)

            {

                Application.Exit();
                return;
            }
        }
    }
}
